from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, PrimaryKeyConstraint
from sqlalchemy.orm import relationship
from datetime import datetime

from ..db import Base

# 文件模型
class File(Base):
    __tablename__ = "files"

    file_name = Column(String, nullable=False)
    file_size = Column(Integer)
    folder_path = Column(String, nullable=False)  # 实际存储文件夹路径

    # 关联关系，文件属于某个用户
    owner_id = Column(Integer, ForeignKey("users.id"))
    owner = relationship("User", back_populates="files")

    __table_args__ = (
        PrimaryKeyConstraint("file_name", "owner_id"),
    )
